package com.aaron.kjviewutils;

import android.Manifest;
import android.content.pm.PackageManager;
import android.os.Build;
import android.os.Bundle;
import android.support.annotation.NonNull;
import android.support.annotation.RequiresApi;
import android.support.design.widget.AppBarLayout;
import android.support.v7.widget.DefaultItemAnimator;
import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.StaggeredGridLayoutManager;
import android.support.v7.widget.Toolbar;
import android.text.TextUtils;
import android.view.Gravity;
import android.view.KeyEvent;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.TextView;
import android.widget.Toast;

import com.aaron.kjviewutils.car.CarsActivity;
import com.aaron.kjviewutils.carte.CarteActivity;
import com.aaron.kjviewutils.driving.DrivingActivity;
import com.aaron.kjviewutils.eventBus.EventBusMsg;
import com.aaron.kjviewutils.flight.FlightActivity;
import com.aaron.kjviewutils.footballleague.FootBallLleagueActivity;
import com.aaron.kjviewutils.footballleague.FootBallLleagueBean;
import com.aaron.kjviewutils.footballleague.FootBallService;
import com.aaron.kjviewutils.glide.GlideCircleTransform;
import com.aaron.kjviewutils.health.HealthActivity;
import com.aaron.kjviewutils.spinkit.PoponDismissListener;
import com.aaron.kjviewutils.stock.StockActivity;
import com.aaron.kjviewutils.today.TodayActivity;
import com.aaron.kjviewutils.utils.ShareUtils;
import com.aaron.kjviewutils.wechatsift.WeChatBean;
import com.aaron.kjviewutils.wechatsift.WeChatSiftActivity;
import com.aaron.kjviewutils.wechatsift.service.WeChatService;
import com.aaron.kjviewutils.widget.BottomPopWin;
import com.aaron.kjviewutils.widget.MenuPopWin;
import com.bigkoo.convenientbanner.ConvenientBanner;
import com.bigkoo.convenientbanner.holder.CBViewHolderCreator;
import com.bigkoo.convenientbanner.listener.OnItemClickListener;
import com.bumptech.glide.Glide;
import com.github.ybq.android.spinkit.Style;
import com.jeremyfeinstein.slidingmenu.lib.SlidingMenu;

import org.greenrobot.eventbus.Subscribe;
import org.greenrobot.eventbus.ThreadMode;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;

import butterknife.Bind;
import butterknife.ButterKnife;
import butterknife.OnClick;
import cn.sharesdk.framework.Platform;
import cn.sharesdk.framework.PlatformActionListener;
import retrofit2.Call;
import retrofit2.Callback;
import retrofit2.Response;

/**
 * 作者：Aaron on 2017/2/15 09:42
 * 邮箱：kaijin.fang@edianniu.com
 */
public class HomeActivity extends BaseActivity{

    @Bind(R.id.homeAppbar)
    AppBarLayout homeAppbar;
    @Bind(R.id.homeToolBar)
    Toolbar homeToolBar;
    @Bind(R.id.barTitle)
    TextView barTitle;
    @Bind(R.id.leftBarIcon)
    ImageView leftBarIcon;
    @Bind(R.id.rightBarIcon)
    ImageView rightBarIcon;
    @Bind(R.id.homeBanner)
    ConvenientBanner homeBanner;
    @Bind(R.id.menuRecyclerView)
    RecyclerView menuRecyclerView;

    private SlidingMenu menu;
    private View slidingMenuView;
    private ImageView userLogo;
    private TextView userTag;
    private RelativeLayout setting01;
    private RelativeLayout setting02;
    private RelativeLayout setting03;
    private ImageView settingIcon01;
    private ImageView settingIcon02;
    private ImageView settingIcon03;
    private List<String> bannerUrls;
    private List<MenuBean> menus;
    private MenuAdapter adapter;
    private FootBallService footBallService;
    private Call<FootBallLleagueBean> callLoadData;
    private WeChatService weChatService;
    private Call<WeChatBean> callLoadWeChat;
    private MenuPopWin menuPopWin;
    private BottomPopWin bottomPop;
    private ShareUtils shareUtils;

    //再按一次退出
    private long exitTime = 0l;

    @OnClick(R.id.leftBarIcon)
    void doLeftBarIcon()
    {
        if(null!=menu)
        {
            menu.showMenu(true);
        }
    }

    @OnClick(R.id.rightBarIcon)
    void doRightBarIcon()
    {
        menuPopWin = new MenuPopWin(HomeActivity.this, HomeActivity.this);
        menuPopWin.showUi(eventBus);
        menuPopWin.setOnDismissListener(new PoponDismissListener(HomeActivity.this));
        menuPopWin.showAsDropDown(rightBarIcon, 0, 0);
    }

    @Subscribe(threadMode = ThreadMode.MAIN, priority = 80)
    public void onEvent(EventBusMsg msg)
    {
        switch (msg.getType())
        {
            case COMMON_CLICK_FIFA:
            {
                //获取联赛数据
                if(null!=progress)
                {
                    progress.showProgress(Style.WAVE);
                    progress.showAtLocation(homeToolBar, Gravity.CENTER, 0, 0);
                    mHandler.post(runnableLoadLleague);
                }
            }
            break;
            case COMMON_CLICK_WECHAT:
            {
                //获取微信精选数据
                if(null!=progress)
                {
                    progress.showProgress(Style.WAVE);
                    progress.showAtLocation(homeToolBar, Gravity.CENTER, 0, 0);
                    mHandler.post(runnableLoadWeChat);
                }
            }
            break;
            case COMMON_CLICK_HEALTH:
            {
                //获取健康数据
                showActivity(HomeActivity.this, HealthActivity.class);
            }
            break;
            case COMMON_CLICK_CARTE:
            {
                //菜谱大全
                showActivity(HomeActivity.this, CarteActivity.class);
            }
            break;
            case COMMON_CLICK_FLIGHT:
            {
                //航班信息
                showActivity(HomeActivity.this, FlightActivity.class);
            }
            break;
            case MENU_SHARE:
            {
                shareUtils = new ShareUtils(new PlatformActionListener() {
                    @Override
                    public void onComplete(Platform platform, int action, HashMap<String, Object> hashMap) {
                        if ( action == Platform.ACTION_SHARE )
                        {
                            showMsg("分享成功");
                        }
                    }

                    @Override
                    public void onError(Platform platform, int i, Throwable throwable) {
                        showMsg("分享失败");
                    }

                    @Override
                    public void onCancel(Platform platform, int i) {
                        showMsg("分享取消");
                    }
                });
                //分享
                bottomPop = new BottomPopWin(HomeActivity.this, HomeActivity.this);
                bottomPop.showUi(BottomPopWin.MsgType.MSG_SHARE, eventBus);
                bottomPop.showAtLocation(homeToolBar, Gravity.BOTTOM, 0, 0);
                bottomPop.setOnDismissListener(new PoponDismissListener(HomeActivity.this));
            }
            break;
            case SHARE_WECHAT:
            {
                if(null!=shareUtils)
                {
                    shareUtils.share("wechat");
                }
            }
            break;
            case SHARE_MOMENTS:
            {
                if(null!=shareUtils)
                {
                    shareUtils.share("moments");
                }
            }
            break;
            default:
                break;
        }
    }

    Runnable runnableLoadLleague = new Runnable() {
        @Override
        public void run() {
            if(null!=retrofit)
            {
                footBallService = retrofit.create(FootBallService.class);
                callLoadData = footBallService.obtainLleagues();
                callLoadData.enqueue(new Callback<FootBallLleagueBean>() {
                    @Override
                    public void onResponse(Call<FootBallLleagueBean> call, Response<FootBallLleagueBean> response) {
                        if(null!=progress)
                        {
                            progress.dismissView();
                        }
                        FootBallLleagueBean footBallLleague = response.body();
                        if("200".equals(footBallLleague.retCode))
                        {
                            //数据获取成功，跳转到联赛详情界面
                            Bundle bundle = new Bundle();
                            bundle.putSerializable("data", footBallLleague);
                            showActivity(HomeActivity.this, FootBallLleagueActivity.class, bundle);
                        }
                        else
                        {
                            Toast.makeText(HomeActivity.this, footBallLleague.msg, Toast.LENGTH_SHORT).show();
                        }
                    }

                    @Override
                    public void onFailure(Call<FootBallLleagueBean> call, Throwable t) {
                        if(null!=progress)
                        {
                            progress.dismissView();
                        }
                        Toast.makeText(HomeActivity.this, "获取联赛数据失败", Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    };

    Runnable runnableLoadWeChat = new Runnable() {
        @Override
        public void run() {
            if(null!=retrofit)
            {
                weChatService = retrofit.create(WeChatService.class);
                callLoadWeChat = weChatService.obtainWeChatSift();
                callLoadWeChat.enqueue(new Callback<WeChatBean>() {
                    @Override
                    public void onResponse(Call<WeChatBean> call, Response<WeChatBean> response) {
                        if(null!=progress)
                        {
                            progress.dismissView();
                        }
                        WeChatBean weChat = response.body();
                        if("200".equals(weChat.retCode))
                        {
                            //数据获取成功，跳转到联赛详情界面
                            Bundle bundle = new Bundle();
                            bundle.putSerializable("data", weChat);
                            showActivity(HomeActivity.this, WeChatSiftActivity.class, bundle);
                        }
                        else
                        {
                            Toast.makeText(HomeActivity.this, weChat.msg, Toast.LENGTH_SHORT).show();
                        }
                    }

                    @Override
                    public void onFailure(Call<WeChatBean> call, Throwable t) {
                        if(null!=progress)
                        {
                            progress.dismissView();
                        }
                        Toast.makeText(HomeActivity.this, "获取微信精选数据失败", Toast.LENGTH_SHORT).show();
                    }
                });
            }
        }
    };

    @RequiresApi(api = Build.VERSION_CODES.M)
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        this.setContentView(R.layout.layout_home);
        ButterKnife.bind(this);
        if(23<=getSDKVersion())
        {
            //android6.0获取权限
            initPermission();
        }
        else
        {
            initTitle();
            initSlidingMenu();
            initBanner();
            initRecycler();
        }
    }

    @RequiresApi(api = Build.VERSION_CODES.M)
    private void initPermission()
    {
        int accounts = checkSelfPermission(Manifest.permission.GET_ACCOUNTS);
        int phoneState = checkSelfPermission(Manifest.permission.READ_PHONE_STATE);
        int readStorage = checkSelfPermission(Manifest.permission.READ_EXTERNAL_STORAGE);
        int writeStorage = checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE);
        if(accounts != PackageManager.PERMISSION_GRANTED ||
                phoneState != PackageManager.PERMISSION_GRANTED ||
                readStorage != PackageManager.PERMISSION_GRANTED ||
                writeStorage != PackageManager.PERMISSION_GRANTED )
        {
            requestPermissions(PERMISSION, 300);
        }
        else {
            initTitle();
            initSlidingMenu();
            initBanner();
            initRecycler();
        }
    }

    @Override
    public void onRequestPermissionsResult(int requestCode, @NonNull String[] permissions, @NonNull int[] grantResults) {
        if(300!=requestCode)
        {
            showMsg("部分权限未获取");
        }
        initTitle();
        initSlidingMenu();
        initBanner();
        initRecycler();
    }

    private void initRecycler()
    {
        menus = new ArrayList<MenuBean>();
        MenuBean menu01 = new MenuBean();
        menu01.id = 1l;
        menu01.menuTag = "天气预报";
        menu01.menuIcon = "http://api.mob.com//images/index/G_01.png";
        menus.add(menu01);
        MenuBean menu02 = new MenuBean();
        menu02.id = 2l;
        menu02.menuTag = "FIFA";
        menu02.menuIcon = "http://api.mob.com//images/index/G_02.png";
        menus.add(menu02);
        MenuBean menu03 = new MenuBean();
        menu03.id = 3l;
        menu03.menuTag = "用户系统";
        menu03.menuIcon = "http://api.mob.com//images/index/G_03.png";
        menus.add(menu03);
        MenuBean menu04 = new MenuBean();
        menu04.id = 4l;
        menu04.menuTag = "微信精选";
        menu04.menuIcon = "http://api.mob.com//images/index/G_01.png";
        menus.add(menu04);
        MenuBean menu05 = new MenuBean();
        menu05.id = 5l;
        menu05.menuTag = "健康大全";
        menu05.menuIcon = "http://api.mob.com//images/index/G_02.png";
        menus.add(menu05);
        MenuBean menu06 = new MenuBean();
        menu06.id = 6l;
        menu06.menuTag = "菜谱大全";
        menu06.menuIcon = "http://api.mob.com//images/index/G_03.png";
        menus.add(menu06);
        MenuBean menu07 = new MenuBean();
        menu07.id = 7l;
        menu07.menuTag = "航班信息";
        menu07.menuIcon = "http://api.mob.com//images/index/G_01.png";
        menus.add(menu07);
        MenuBean menu08 = new MenuBean();
        menu08.id = 8l;
        menu08.menuTag = "全球股市";
        menu08.menuIcon = "http://api.mob.com//images/index/G_02.png";
        menus.add(menu08);
        MenuBean menu09 = new MenuBean();
        menu09.id = 9l;
        menu09.menuTag = "汽车信息查询";
        menu09.menuIcon = "http://api.mob.com//images/index/G_03.png";
        menus.add(menu09);
        MenuBean menu010 = new MenuBean();
        menu010.id = 10l;
        menu010.menuTag = "驾考题库";
        menu010.menuIcon = "http://api.mob.com//images/index/G_01.png";
        menus.add(menu010);
        MenuBean menu011 = new MenuBean();
        menu011.id = 11l;
        menu011.menuTag = "历史上的今天";
        menu011.menuIcon = "http://api.mob.com//images/index/G_02.png";
        menus.add(menu011);
        // 错列网格布局
        menuRecyclerView.setLayoutManager(new StaggeredGridLayoutManager(3,
                StaggeredGridLayoutManager.VERTICAL));
        adapter = new MenuAdapter(HomeActivity.this, menus);
        menuRecyclerView.setAdapter(adapter);
        menuRecyclerView.addItemDecoration(new RecyclerDividerForOther(HomeActivity.this, 3));
        menuRecyclerView.setItemAnimator(new DefaultItemAnimator()); // 默认动画
        adapter.setmOnItemClickListener(new MenuAdapter.OnItemClickListener() {
            @Override
            public void onItemClick(View view, int position) {
                //点击事件
                MenuBean menu = menus.get(position);
                switch (menu.menuTag)
                {
                    case "天气预报":
                    {
                        showActivity(HomeActivity.this, MainActivity.class);
                    }
                    break;
                    case "FIFA":
                    {
                        eventBus.post(new EventBusMsg(EventBusMsg.EventBusType.COMMON_CLICK_FIFA));
                    }
                    break;
                    case "用户系统":
                    {
                        if(TextUtils.isEmpty(obtainToken()))
                        {
                            //未登录，进入登录界面
                            showActivity(HomeActivity.this, LoginActivty.class);
                        }
                        else
                        {
                            //进入用户中心
                            showActivity(HomeActivity.this, UserPorfileActivity.class);
                        }
                    }
                    break;
                    case "微信精选":
                    {
                        eventBus.post(new EventBusMsg(EventBusMsg.EventBusType.COMMON_CLICK_WECHAT));
                    }
                    break;
                    case "健康大全":
                    {
                        eventBus.post(new EventBusMsg(EventBusMsg.EventBusType.COMMON_CLICK_HEALTH));
                    }
                    break;
                    case "菜谱大全":
                    {
                        eventBus.post(new EventBusMsg(EventBusMsg.EventBusType.COMMON_CLICK_CARTE));
                    }
                    break;
                    case "航班信息":
                    {
                        eventBus.post(new EventBusMsg(EventBusMsg.EventBusType.COMMON_CLICK_FLIGHT));
                    }
                    break;
                    case "全球股市":
                    {
                        showActivity(HomeActivity.this, StockActivity.class);
                    }
                    break;
                    case "汽车信息查询":
                    {
                        showActivity(HomeActivity.this, CarsActivity.class);
                    }
                    break;
                    case "驾考题库":
                    {
                        showActivity(HomeActivity.this, DrivingActivity.class);
                    }
                    break;
                    case "历史上的今天":
                    {
                        showActivity(HomeActivity.this, TodayActivity.class);
                    }
                    break;
                    default:
                        break;
                }
            }
        });
    }

    private void initTitle()
    {
        homeToolBar.setTitle("");
        barTitle.setText("mobAPI首页");
        loadBackground(leftBarIcon, resources.getDrawable(R.mipmap.menu));
        loadBackground(rightBarIcon, resources.getDrawable(R.mipmap.title_right));
        homeToolBar.setNavigationIcon(null);
    }

    @Override
    protected void onResume() {
        super.onResume();
        if(null!=homeBanner)
        {
            homeBanner.startTurning(5000);
        }
    }

    @Override
    protected void onPause() {
        super.onPause();
        if(null!=homeBanner)
        {
            homeBanner.stopTurning();
        }
    }

    private void initBanner()
    {
        bannerUrls = new ArrayList<String>();
        bannerUrls.add("http://api.mob.com/images/index/F_02.png");
        bannerUrls.add("http://api.mob.com/images/index/F_06_02.png");
        bannerUrls.add("http://api.mob.com/images/index/F_03_02.png");
        bannerUrls.add("http://api.mob.com/images/index/F_04_02.png");
        bannerUrls.add("http://api.mob.com/images/index/F_05_02.png");
        homeBanner.setPages(new CBViewHolderCreator<NetworkImageHolderView>() {
            @Override
            public NetworkImageHolderView createHolder() {
                return new NetworkImageHolderView();
            }
        }, bannerUrls).setPointViewVisible(true)    //设置指示器是否可见
            .setPageIndicator(new int[]{R.mipmap.index_white, R.mipmap.index_red})//设置指示器圆点
            .startTurning(5000)     //设置自动切换（同时设置了切换时间间隔）
            .setPageIndicatorAlign(ConvenientBanner.PageIndicatorAlign.CENTER_HORIZONTAL) //设置指示器位置（左、中、右）
            .setManualPageable(true); //设置点击监听事件;
        homeBanner.setOnItemClickListener(new OnItemClickListener() {
            @Override
            public void onItemClick(int i) {
                showMsg("你点击了"+i+"个banner图");
            }
        });
    }

    private void initSlidingMenu()
    {
        // configure the SlidingMenu
        menu = new SlidingMenu(this);
        menu.setMode(SlidingMenu.LEFT);
        // 设置触摸屏幕的模式
        menu.setTouchModeAbove(SlidingMenu.TOUCHMODE_NONE);
        menu.setShadowWidthRes(R.dimen.shadow_width);
        menu.setShadowDrawable(R.drawable.shadow);

        // 设置滑动菜单视图的宽度
        menu.setBehindOffsetRes(R.dimen.slidingmenu_offset);
        // 设置渐入渐出效果的值
        menu.setFadeDegree(0.5f);
        menu.attachToActivity(this, SlidingMenu.SLIDING_CONTENT);
        //为侧滑菜单设置布局
        slidingMenuView = View.inflate(HomeActivity.this, R.layout.layout_sliding, null);
        userLogo = (ImageView) slidingMenuView.findViewById(R.id.userLogo);
        userTag = (TextView) slidingMenuView.findViewById(R.id.userTag);
        setting01 = (RelativeLayout) slidingMenuView.findViewById(R.id.setting01);
        setting02 = (RelativeLayout) slidingMenuView.findViewById(R.id.setting02);
        setting03 = (RelativeLayout) slidingMenuView.findViewById(R.id.setting03);
        settingIcon01 = (ImageView) slidingMenuView.findViewById(R.id.settingIcon01);
        settingIcon02 = (ImageView) slidingMenuView.findViewById(R.id.settingIcon02);
        settingIcon03 = (ImageView) slidingMenuView.findViewById(R.id.settingIcon03);
        menu.setMenu(slidingMenuView);
        mHandler.postDelayed(runnableLoadMenu, 1000);
        setting01.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null!=menu)
                {
                    menu.toggle();
                }
                Bundle bundle = new Bundle();
                bundle.putString("title", "mobAPI介绍");
                bundle.putString("url", "http://m.so.com/index.php?a=newTranscode&u=http%3A%2F%2Fwww.mob.com%2F&m=de1188ad56cbc18560e2a0bffa2cf00e63e1704b&q=mobapi#tt_daymode=1&tt_font=m");
                showActivity(HomeActivity.this, MobDetailActivity.class, bundle);
            }
        });

        setting02.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null!=menu)
                {
                    menu.toggle();
                }
                showActivity(HomeActivity.this, SettingActivity.class);
            }
        });

        setting03.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                if(null!=menu)
                {
                    menu.toggle();
                }
                Bundle bundle = new Bundle();
                bundle.putString("title", "联系我们");
                bundle.putString("url", "http://m.so.com/index.php?a=newTranscode&u=http%3A%2F%2Fwww.mob.com%2F&m=de1188ad56cbc18560e2a0bffa2cf00e63e1704b&q=mobapi#tt_daymode=1&tt_font=m");
                showActivity(HomeActivity.this, MobDetailActivity.class, bundle);
            }
        });
    }

    Runnable runnableLoadMenu = new Runnable() {
        @Override
        public void run() {
            Glide.with(HomeActivity.this).load("http://imgsrc.baidu.com/forum/w=580/sign=014774f5231f95caa6f592bef9167fc5/a4bf060828381f307f69fc22af014c086f06f05d.jpg").transform(new GlideCircleTransform(HomeActivity.this)).dontAnimate().placeholder(R.mipmap.ic_launcher).into(userLogo);
            userTag.setText("小卢比");
            Glide.with(HomeActivity.this).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487074487176&di=6ee1ab8986995bcf2f9300f2edbcd534&imgtype=0&src=http%3A%2F%2Fscimg.jb51.net%2Fallimg%2F160316%2F77-160316144F60-L.jpg").transform(new GlideCircleTransform(HomeActivity.this)).animate(android.R.anim.slide_in_left).placeholder(R.mipmap.ic_launcher).into(settingIcon01);
            Glide.with(HomeActivity.this).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487074556581&di=47217d3e5bba675e86f2632d6994d98e&imgtype=0&src=http%3A%2F%2Ff.hiphotos.baidu.com%2Fexp%2Fw%3D480%2Fsign%3Db784207419178a82ce3c7ea8c602737f%2F10dfa9ec8a1363275772188b968fa0ec09fac7ef.jpg").transform(new GlideCircleTransform(HomeActivity.this)).animate(android.R.anim.slide_in_left).placeholder(R.mipmap.ic_launcher).into(settingIcon02);
            Glide.with(HomeActivity.this).load("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1487074585677&di=42888d3aaa2504cdda2668c76718a5cc&imgtype=0&src=http%3A%2F%2Fimgs.ebrun.com%2Fresources%2F2015_03%2F2015_03_16%2F20150316_1426477906046.jpg").transform(new GlideCircleTransform(HomeActivity.this)).animate(android.R.anim.slide_in_left).placeholder(R.mipmap.ic_launcher).into(settingIcon03);
        }
    };

    @Override
    public boolean onKeyDown(int keyCode, KeyEvent event) {
        if (keyCode == KeyEvent.KEYCODE_BACK
                && event.getAction() == KeyEvent.ACTION_DOWN)
        {
            if(null!=menu&&menu.isMenuShowing())
            {
                menu.toggle();
            }
            else if(null!=menu&&!menu.isMenuShowing())
            {
                if ((System.currentTimeMillis() - exitTime) > 2000)
                {
                    Toast.makeText(HomeActivity.this, "再按一次退出程序", Toast.LENGTH_LONG).show();
                    exitTime = System.currentTimeMillis();
                } else
                {
                    closeSelf(HomeActivity.this);
                    killAppDestory(HomeActivity.this);
                }
            }
            return true;
        }
        return super.onKeyDown(keyCode, event);
    }

    @Override
    protected void onDestroy() {
        super.onDestroy();
        if(null!=mHandler)
        {
            mHandler.removeCallbacks(runnableLoadMenu);
            mHandler.removeCallbacks(runnableLoadLleague);
            mHandler.removeCallbacks(runnableLoadWeChat);
        }
        if(null!=menuPopWin)
        {
            menuPopWin.dismissView();
        }
        if(null!=bottomPop)
        {
            bottomPop.dismissView();
        }
        if(null!=callLoadData)
        {
            callLoadData.cancel();
        }
        if(null!=callLoadWeChat)
        {
            callLoadWeChat.cancel();
        }
        ButterKnife.unbind(this);
    }
}
